package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.CartoonEveryDayPreviewDataBean;
import com.fancy.learncenter.common.Constant;
import com.fancy.learncenter.ui.activity.CartoonDetailActivity;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;
import com.fancy.learncenter.ui.fragment.CartoonSentenceSpeakFragment;
import com.fancy.learncenter.utils.FileUtils;

import java.util.List;

/**
 * Created by hyy on 2018/5/10.
 */

public class CartoonTeacherEveryDayPreviewAdapter extends CommonRecycleViewAdapter<CartoonEveryDayPreviewDataBean.ResultBean.GrammerSpeakListBean> {
    public CartoonTeacherEveryDayPreviewAdapter(Context mContext, List<CartoonEveryDayPreviewDataBean.ResultBean.GrammerSpeakListBean> itemDatas) {
        super(mContext, R.layout.activity_everyday_preview_sentence, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final CartoonEveryDayPreviewDataBean.ResultBean.GrammerSpeakListBean item, int position) {

        TextView text_name = customViewHold.getView(R.id.text_name);
        text_name.setText(item.getQuestionName());

        TextView time = customViewHold.getView(R.id.time);
        time.setText(item.getResourceDuration());

        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, CartoonDetailActivity.class);
                intent.putExtra("type", "2");
                intent.putExtra(CartoonDetailActivity.QUESTION_ID, item.getSubjectQuestionId());
                intent.putExtra(CartoonDetailActivity.ANSWER_KEY, item.getAnswerResourceUrls().get(0));
                intent.putExtra(CartoonDetailActivity.LOCAL_FILE_PATH, FileUtils.getExpandRecorderAudioPath() + item.getSubjectQuestionId() + Constant.DIVID_CODE + item.getCommitTime().split(" ")[0] + Constant.DIVID_CODE + CartoonSentenceSpeakFragment.RELEASE_FALG + "/");
                mContext.startActivity(intent);
            }
        });
    }
}
